/*****************************************************************************
 * Copyright (C) Stacy Curl. All rights reserved.                            *
 * ------------------------------------------------------------------------- *
 * The software in this package is published under the terms of the BSD      *
 * style license a copy of which has been included with this distribution in *
 * the LICENSE.txt file.                                                     *
 *****************************************************************************/
package picounit.features.registry;

import java.util.HashSet;
import java.util.Set;

public class ClassUtil {
	private final Set<Class<?>> simpleTypes = simpleTypes();

	public boolean isSimple(Class<?> type) {
		return simpleTypes.contains(type);
	}

	public boolean isPrimative(Class<?> type) {
		return !type.equals(Object.class) && isSimple(type);
	}
	
	///////////////////////////////////////////////////////////////////////////////////////////////
	// Implementation methods
	///////////////////////////////////////////////////////////////////////////////////////////////
	
	private Set<Class<?>> simpleTypes() {
		Set<Class<?>> simpleTypes = new HashSet<Class<?>>();

		simpleTypes.add(boolean.class);
		simpleTypes.add(byte.class);
		simpleTypes.add(char.class);
		simpleTypes.add(double.class);
		simpleTypes.add(float.class);
		simpleTypes.add(int.class);
		simpleTypes.add(long.class);
		simpleTypes.add(short.class);
		simpleTypes.add(Boolean.class);
		simpleTypes.add(Byte.class);
		simpleTypes.add(Character.class);
		simpleTypes.add(Double.class);
		simpleTypes.add(Float.class);
		simpleTypes.add(Integer.class);
		simpleTypes.add(Long.class);
		simpleTypes.add(Short.class);
		simpleTypes.add(String.class);
		simpleTypes.add(Object.class);

		return simpleTypes;
	}
}
